﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace Clipper.EngineerWindow
{
    /// <summary>
    /// UserValveCmd.xaml 的交互逻辑
    /// </summary>
    public partial class UserValveCmd : UserControl
    { 
        public delegate void ValveDelg(bool open);
        public event ValveDelg InValve;
        public event ValveDelg OutValve;
        public event ValveDelg IslValve;

        public UserValveCmd()
        {
            InitializeComponent();
        }
        public string Title
        {
            get
            {
                return txtTitle.Text;
            }
            set
            {
                txtTitle.Text = value;
            }
        }
        /// <summary>
        /// 初始化
        /// </summary>
        public void Init(ValveDelg InEvent,ValveDelg OutEvent,ValveDelg IslEvent)
        {
            
            InValve = InEvent;
            OutValve = OutEvent;
            IslValve = IslEvent;
        }

        private void ValveClick(object sender, RoutedEventArgs e)
        {
            
            string btnName = ((Button)sender).Name;
            switch (btnName)
            {
                case "btnInOpen":
                    InValve.Invoke(true);
                    break;
                case "btnInClose":
                    InValve.Invoke(false);
                    break;
                case "btnOutOpen":
                    OutValve.Invoke(true);
                    break;
                case "btnOutClose":
                    OutValve.Invoke(false);
                    break;
                case "btnIslOpen":
                    IslValve.Invoke(true);
                    break;
                case "btnIslClose":
                    IslValve.Invoke(false);
                    break;
            }
        }

    }
}
